// store/index.js
import { createStore } from 'vuex';

export default createStore({
  state: {
    currentAngle: -90,
    topCardIndex: 0,
    cards: [],
    outerBgColor: '#f0f0f0'
  },
  mutations: {
    setCurrentAngle(state, angle) {
      state.currentAngle = angle;
    },
    setTopCardIndex(state, index) {
      state.topCardIndex = index;
    },
    setCards(state, cards) {
      state.cards = cards;
    },
    setOuterBgColor(state, color) {
      state.outerBgColor = color;
    }
  },
  actions: {
    saveState({ commit }, { currentAngle, topCardIndex, cards, outerBgColor }) {
      commit('setCurrentAngle', currentAngle);
      commit('setTopCardIndex', topCardIndex);
      commit('setCards', cards);
      commit('setOuterBgColor', outerBgColor);
    },
    loadState({ state }) {
      return {
        currentAngle: state.currentAngle,
        topCardIndex: state.topCardIndex,
        cards: state.cards,
        outerBgColor: state.outerBgColor
      };
    }
  }
});
